<?php
//$startTime = microtime(true);
define('BASE_URL', '/');

defined('BASE_PATH')
    || define('BASE_PATH', realpath(dirname(__FILE__)));

defined('PUBLIC_PATH')
    || define('PUBLIC_PATH', realpath(dirname(__FILE__) . '/../public'));

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(BASE_PATH . '/../application'));

defined('EMPLOYEE_IMAGE_PATH')
    || define('EMPLOYEE_IMAGE_PATH', realpath(BASE_PATH . '/../public/files/employee'));

defined('TEMPLATES_IMAGE_PATH')
    || define('TEMPLATES_IMAGE_PATH', realpath(BASE_PATH . '/../public/files/templates'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

require_once 'Zend/Cache.php';
require_once 'Zend/Registry.php';
$frontendOptions = array(
   'lifetime' => 30*60,
   'automatic_serialization' => true
);

$backendOptions = array(
    'cache_dir' => '../cache/'
);
$frontend = 'Core';
$backend = 'File';
$cache = Zend_Cache::factory($frontend, $backend, $frontendOptions, $backendOptions);
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);
Zend_Registry::set ( 'cache', $cache );

/** Composer autoloader */
require_once __DIR__ . '/../vendor/autoload.php';

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
//    APPLICATION_PATH . '/configs/application.ini'
    APPLICATION_PATH . '/configs/config.yaml'
);

$application->bootstrap()
            ->run();

//$time = round(microtime(true) - $startTime, 4);
//$memory = round(memory_get_peak_usage(true) / 1024);
//$files = count(get_included_files());
///echo 'time'.$time.'<br/>';;
//echo $memory.'<br/>';
//echo $files.'<br/>';;
